package com.leancloud.circle.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.LinearLayout;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.leancloud.circle.R;
import com.leancloud.circle.adapter.DiscussAdapter;
import com.leancloud.circle.manage.CirclePathManage;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import tech.com.commoncore.base.BaseTitleActivity;
import tech.com.commoncore.view.SpaceItemDecoration;

@Route(path = CirclePathManage.CIRCLE_TOPIC_LIST)
public class TopicActivity extends BaseTitleActivity {

    private SmartRefreshLayout smartRefresh;
    private RecyclerView dataRecyclerView;
    private DiscussAdapter discussAdapter;
    private LinearLayout noDataLayout;

    @Override
    public void setTitleBar(TitleBarView titleBar) {

    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_topic;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        noDataLayout = mContentView.findViewById(R.id.not_data_layout);
        smartRefresh = mContentView.findViewById(R.id.smart_refresh_layout);
        dataRecyclerView = mContentView.findViewById(R.id.discuss_recycler);
        discussAdapter = new DiscussAdapter(R.layout.circle_layout_item_discuss);

        int space = (int) getResources().getDimension(R.dimen.dp_6);
        SpaceItemDecoration decoration = new SpaceItemDecoration(space);
        dataRecyclerView.addItemDecoration(decoration);
        dataRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        dataRecyclerView.setAdapter(discussAdapter);

        smartRefresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                requestData();
            }
        });

//        if (dataAVObjectList == null || dataAVObjectList.isEmpty()) {
//            smartRefresh.autoRefresh();
//        }
    }

    private void requestData() {

    }

    private void upDateView() {
//        if (dataAVObjectList == null || dataAVObjectList.isEmpty()) {
//            noDataLayout.setVisibility(View.VISIBLE);
//        } else {
//            noDataLayout.setVisibility(View.GONE);
//            discussAdapter.replaceData(dataAVObjectList);
//            discussAdapter.notifyDataSetChanged();
//        }
    }
}
